package com.zb.controller;

import com.zb.entity.Users;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by 11965 on 2019/7/8.
 */
//@RestController = @Controller+@ResponseBody
@RestController
public class HelloController {


    //@GetMapping   = @RequestMapping(method= RequestMethod.GET,value="请求地址")
    //@PostMapping = @RequestMapping(method= RequestMethod.POST,value="请求地址")
    //@PutMapping = @RequestMapping(method= RequestMethod.put,value="请求地址")
    //@DeleteMapping = @RequestMapping(method= RequestMethod.DELETE,value="请求地址")
    @PostMapping("hello")
    public String hello(){
        return "hello";
    }

    //springBoot内置 jackson工具包
    //返回值是List Map  entity对象时   解析成json
    @GetMapping("listUsers")
    public List<Users> listUsers(){
        List<Users> list = new ArrayList<>();
        list.add(new Users(1,"韩天一",new Date()));
        list.add(new Users(2,"王润民",new Date()));
        list.add(new Users(3,"胡刚军",new Date()));
        return list;
    }

}
